<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>登录页面</title>
		<!-- 样 式 文 件 -->
		<link rel="stylesheet" href="__COMPONENT__/pear/css/pear.css" />
		<link rel="stylesheet" href="__ADMIN__/css/other/login.css" />
	</head>
    <!-- 代 码 结 构 -->
	<body background="__ADMIN__/images/background.svg" style="background-size: cover;">
		<form class="layui-form" action="javascript:void(0);">
			<div class="layui-form-item">
				<img class="logo" src="__ADMIN__/images/logo.png" />
				<div class="title">Admin Demo</div>
			</div>
			<div class="layui-form-item">
				<input type="text" name="username" placeholder="账 户 : admin " hover class="layui-input"  />
			</div>
			<div class="layui-form-item">
				<input  type="password" name="password" placeholder="密 码 : admin " hover class="layui-input"  />
			</div>
			<div class="layui-form-item">
				<input type="text" name="verifyCode" placeholder="验证码 : "  hover class="code layui-input layui-input-inline"  />
				<img src="__HOST__/login/verify" class="codeImage" alt="点击更新"/>
			</div>
			<div class="layui-form-item">
				<input type="checkbox" name="" title="记住密码" lay-skin="primary" checked>
			</div>
			<div class="layui-form-item">
				<button type="button" class="pear-btn pear-btn-success login" lay-submit lay-filter="login">
					登 入
				</button>
			</div>
		</form>
		<!-- 资 源 引 入 -->
		<script src="__COMPONENT__/layui/layui.js"></script>
		<script src="__COMPONENT__/pear/pear.js"></script>
		<script>
			layui.use(['form', 'button','jquery','layer'], function() {
				var form = layui.form;
				var $ = layui.jquery;
				var layer = layui.layer;

				//点击更新验证码
				$(".codeImage").click(function (){
					//重新设置值
					this.src = "__HOST__/login/verify?date="+new Date().valueOf();
				})

                // 登 录 提 交
				form.on('submit(login)', function(data) {
					//用户登录Ajax
					$.ajax({
						//请求方式
						type : "POST",
						//请求的媒体类型
						contentType: "application/json;charset=UTF-8",
						//请求地址
						url : "__HOST__/login/login",
						//数据，json字符串
						data : JSON.stringify(data.field),
						//请求成功
						success : function(result) {
							if (result['code'] == 200){
								layer.msg(result['msg'],{icon:1,time:1200,skin:'success',offset:'10px'},function (){
									//登录成功跳转首页
									location.href = '__HOST__/index/index';
								});
							}else{
								layer.msg(result['msg'],{icon:2,time:1200,skin:'success',offset:'10px'},function (){
									//更新验证码
									$(".codeImage").attr('src',"__HOST__/login/verify?date="+new Date().valueOf());
								});
							}

						},
						//请求失败，包含具体的错误信息
						error : function(e){
						}
					});
					return false;
				});

			})
		</script>
	</body>
</html>
